package com.manner.groupon.controller.user;

import com.manner.groupon.common.BaseResponse;
import com.manner.groupon.common.ResultUtils;
import com.manner.groupon.model.dto.deuctionCoupon.UserGetDeductionCouponVo;
import com.manner.groupon.service.groupon.DeductionCouponService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Author: Manner
 * @Description: 订单抵扣券请求控制器
 * @DateTime: 2024/12/1 23:11
 */
@RestController
@RequestMapping("/user/deduction")
@RequiredArgsConstructor
public class DeductionCouponController {

    private final DeductionCouponService deductionCouponService;

    /**
     * @param shareUserPhone       分享人手机号
     * @param receiveUserPhone     领取人手机号
     * @param shareGiveCouponId 分享赠送的直减订单金额优惠券编号
     * @return BaseResponse
     * @description: 微信小程序分享转发给朋友, 赠送的直减订单金额的优惠券编号
     * @author Manner
     * @date 2024/12/2 15:07
     */
    @PostMapping("/share-give/{shareUserPhone}/{receiveUserPhone}/{shareGiveCouponId}")
    public BaseResponse shareGive(@PathVariable String shareUserPhone,
                                  @PathVariable String receiveUserPhone,
                                  @PathVariable Long shareGiveCouponId) {
        return ResultUtils.success(deductionCouponService.shareGiveGrouponCouponOrder(shareUserPhone, receiveUserPhone, shareGiveCouponId));
    }

    /**
     * @param phone
     * @return BaseResponse<List < DeductionCoupon>>
     * @description: 获取当前登录用户的所有优惠券信息
     * @author Manner
     * @date 2024/12/1 23:55
     */
    @GetMapping("/{phone}")
    public BaseResponse<List<UserGetDeductionCouponVo>> getMyAllCoupon(@PathVariable String phone) {
        return ResultUtils.success(deductionCouponService.getMyAllDeductionCoupon(phone));
    }

}
